package com.xucan.anno.mainx;

import lombok.Data;

import java.lang.reflect.Method;
@Data
class User {
    private int age;
    @TestAnno
    private String name;

    public void say(){

    }

    public static void m1(){
//        Retention
        User cat = new User();
        Long  start=System.currentTimeMillis();
        for (int i=0;i<10000000;i++){
            cat.say();
        }
        Long  end=System.currentTimeMillis();
        System.out.println("耗时"+(end-start));
    }
    public static void m2()throws Exception{
        Class<?> aClass = Class.forName("com.xucan.class.User");
        Object o = aClass.newInstance();
        Method method = aClass.getMethod("say");
        Long  start=System.currentTimeMillis();
        for (int i=0;i<10000000;i++){
            method.invoke(o);
        }
        Long  end=System.currentTimeMillis();
        System.out.println("耗时"+(end-start));
    }

    public static void main(String[] args) throws Exception{
       m1();
       m2();
    }


    public User() {
        super();
    }

    private User(String name) {
        super();
        this.name = name;
    }

    private User(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
